

import static org.junit.Assert.assertEquals;
import junit.framework.TestCase;

/**
 *
 */
public class CoffeeMakerTest extends TestCase {
	public CoffeeMaker cm;
	public Inventory i;
	public Recipe r1;

	public void setUp() {
		cm = new CoffeeMaker();
		i = cm.checkInventory();

		r1 = new Recipe();
		r1.setName("Coffee");
		r1.setPrice(50);
		r1.setAmtCoffee(6);
		r1.setAmtMilk(1);
		r1.setAmtSugar(1);
		r1.setAmtChocolate(1);
	}
	
	public void tearDown() throws Exception {
		cm = null;
		i = null;
		r1 = null;
	}
		
	public void testAddRecipe1() {
		assertTrue(cm.addRecipe(r1));
	}

	public void testAddRecipe2() {
		cm.addRecipe(r1);
		assertFalse(cm.addRecipe(r1));
	}
	
	public void testAddRecipe3() {
		
		Recipe r2;
		Recipe r3;
		Recipe r4;
		Recipe r5;
		r2 = r1;
		r3 = r1;
		r4 = r1;
		r5 = r1;
		cm.addRecipe(r1);
		cm.addRecipe(r2);
		cm.addRecipe(r3);
		cm.addRecipe(r4);
		assertFalse(cm.addRecipe(r5));
	}
	
	public void testDeleteRecipe1() {
		cm.addRecipe(r1);
		assertTrue(cm.deleteRecipe(r1));
	}
	
	public void testDeleteRecipe2() {
		r1 = null;
		assertFalse(cm.deleteRecipe(r1));
	}

	public void testEditRecipe1() {
		cm.addRecipe(r1);
		Recipe newRecipe = new Recipe();
		newRecipe = r1;
		newRecipe.setAmtSugar(2);
		assertTrue(cm.editRecipe(r1, newRecipe));
	}
	
	public void testAddInventory1() {
		int amtCoffee = 1;
		int amtMilk = 1;
		int amtSugar = 1;
		int amtChocolate = 1;
		
		cm.addInventory(amtCoffee, amtMilk, amtSugar, amtChocolate);
		
		assertEquals(16, i.getCoffee(), 0);
		assertEquals(16,i.getMilk(),0);
		assertEquals(16,i.getSugar(),0);
		assertEquals(16,i.getChocolate(),0);
	}
	
	public void testAddInventory2() {
		int amtCoffee = 1;
		int amtMilk = 1;
		int amtSugar = 1;
		int amtChocolate = -1;
		
		assertFalse(cm.addInventory(amtCoffee, amtMilk, amtSugar, amtChocolate));
	}
	
	public void testAddInventory3() {
		int amtCoffee = -1;
		int amtMilk = 1;
		int amtSugar = 1;
		int amtChocolate = 1;
		
		assertFalse(cm.addInventory(amtCoffee, amtMilk, amtSugar, amtChocolate));
	}
	
	public void testAddInventory4() {
		int amtCoffee = 1;
		int amtMilk = -1;
		int amtSugar = 1;
		int amtChocolate = 1;
		
		assertFalse(cm.addInventory(amtCoffee, amtMilk, amtSugar, amtChocolate));
	}
	
	public void testAddInventory5() {
		int amtCoffee = 1;
		int amtMilk = 1;
		int amtSugar = -1;
		int amtChocolate = 1;
		
		assertFalse(cm.addInventory(amtCoffee, amtMilk, amtSugar, amtChocolate));
	}
	
	public void testPurchaseBeverage1() {
		
		assertEquals(10, cm.makeCoffee(r1, 60), 0);
		assertEquals(9, i.getCoffee(), 0);
		assertEquals(14, i.getMilk(), 0);
		assertEquals(14, i.getSugar(), 0);
		assertEquals(14, i.getChocolate(), 0);
	}
	
	public void testPurchaseBeverage2() {
		
		assertEquals(30, cm.makeCoffee(r1, 30), 0);
	}
	
	public void testPurchaseBeverage3() {
		i.setChocolate(0);
		i.setCoffee(0);
		i.setMilk(0);
		i.setSugar(0);
		
		assertEquals(100,cm.makeCoffee(r1, 100),0);
	}
	
	public void testGetRecipe() {
		cm.getRecipes();
	}
	
	public void testGetRecipeForName1() {
		cm.addRecipe(r1);
		assertEquals(r1,cm.getRecipeForName("Coffee"));
	}
	

	
}